package com.example.demoserver.controller;

import com.example.demoserver.entity.InteGoods;
import com.example.demoserver.entity.InteIdentify;
import com.example.demoserver.entity.InteSaleorder;
import com.example.demoserver.service.InteGoodsService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@RequiredArgsConstructor
@Component
public class InteGoodsController {
    private final InteGoodsService inteGoodsService;
    @GetMapping("/selectall")
    public List<InteGoods> selectAll(){
        List<InteGoods> list=inteGoodsService.selectAll();
        return list;
    }

    @PostMapping("/insert")
    public InteGoods goodsInsert(@RequestBody InteGoods inteGoods){
        boolean bol=inteGoodsService.save(inteGoods);
        if(bol) return inteGoods;
        return null;
    }

    @PostMapping("/update")
    public InteGoods goodsUpdate(@RequestBody InteGoods inteGoods){
        boolean bol=inteGoodsService.updateById(inteGoods);
        if(bol) return inteGoods;
        return null;
    }

    @GetMapping("/delete")
    public Integer goodsDelete(Integer id){
        return inteGoodsService.deleteByid(id);
    }


}
